package ch.exploadingelephants.model;

import java.util.List;

import android.content.res.Resources;
import android.graphics.Bitmap;
import ch.exploadingelephants.graph.DotColor;
import ch.exploadingelephants.graph.Token;
import ch.exploadingelephants.graph.WriterToken;

/**
 * @author Sandro De Zanet
 * 
 */
public class WriterItem extends MachineItem {
    private final ConveyorDirection direction;
    private final DotColor color;

    /**
     * @param view
     */
    public WriterItem(DotColor color, ConveyorDirection direction) {
	this.direction = direction;
	this.color = color;
    }

    /*
     * (non-Javadoc)
     * 
     * @see ch.exploadingelephants.model.MachineItem#getBitmap()
     */
    @Override
    public List<Bitmap> getBitmaps(Resources resources) {
	switch (color) {
	case RED:
	    return loadBitmaps(direction.getRwResourceID(), resources);
	case BLUE:
	    return loadBitmaps(direction.getBwResourceID(), resources);
	default:
	    return loadBitmaps(direction.getRwResourceID(), resources);
	}
    }

    /*
     * (non-Javadoc)
     * 
     * @see ch.exploadingelephants.model.MachineItem#createGraphObject()
     */
    @Override
    public Token createGraphObject() {
	return new WriterToken(color, direction);
    }

    /*
     * (non-Javadoc)
     * 
     * @see ch.exploadingelephants.model.MachineItem#copyItem()
     */
    @Override
    public MachineItem copyItem() {
	return new WriterItem(color, direction);
    }

}
